package day7;

import day5.Person;

/*
* 多态转型
* */
public class Demo4 {
    public static void main(String[] args) {
//
//        //多态本事就是向上转型，将子类的对象赋值给父类引用
//        Demo2Fu demo2Fu = new Demo2Zi();
//
//
//        //向下转型，将多态定义的对象再转为子类的引用,需要强制类型转换
//        Demo2Zi demo2Zi = (Demo2Zi) demo2Fu;
//
//        Demo2Zi demo2Zi1 = new Demo2Zi();

        Demo4Person demo4PersonWorker = new Worker();

        Demo4Person demo4PersonWaiter = new Waiter();

        look(demo4PersonWorker);
        look(demo4PersonWaiter);
    }

    //观看人的工作内容
    public static void look(Demo4Person person){
        person.work();
    }
}

//父类
abstract class Demo4Person{

    public abstract void work();

}

//子类工人
class Worker extends Demo4Person{

    @Override
    public void work() {
        System.out.println("抡大锤");
    }
}

//子类 服务生
class Waiter extends Demo4Person{
    @Override
    public void work() {
        System.out.println("端盘子, show才艺");
    }
}